import {onMounted, reactive} from "vue";
import axios from "axios";

export default () => {
    // https://dog.ceo/api/breeds/image/random
    let dogList = reactive([
        'https://images.dog.ceo/breeds/pembroke/n02113023_1373.jpg',
    ])

    const getDog = async () => {
        try {
            let result = await axios.get('https://dog.ceo/api/breeds/image/random')
            dogList.push(result.data.message)
        } catch (e) {
            alert(e)
        }
    }
    // 钩子
    onMounted(async () => {
        await getDog();
    })
    // 向外部提供东西
    return {
        dogList,
        getDog
    }
}
